local fangzhu = fk.CreateSkill{
    name = "hs__fangzhu",
}

fangzhu:addEffect(fk.Damaged,{
    anim_type = "masochism",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(fangzhu.name) and #player.room:getOtherPlayers(player, false) > 0
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local to = room:askToChoosePlayers(player,{
            targets = room:getOtherPlayers(player, false),
            min_num = 1,
            max_num = 1,
            prompt = "#hs__fangzhu-choose:::"..player:getLostHp(),
            skill_name = fangzhu.name,
            cancelable = true,
        })
        if #to > 0 then
          event:setCostData(self, {tos = to})
          return true
        end
      end,
      on_use = function(self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        local num = player:getLostHp()
        if num > 0 then
          if to.hp > 0 and #room:askToDiscard(to,{
            min_num = num,
            max_num = num,
            include_equip = true,
            prompt = "#hs__fangzhu-ask:::"..num,
            skill_name = fangzhu.name,
            cancelable = true,
          }) > 0 then
            if not to.dead then
              room:loseHp(to, 1, fangzhu.name)
            end
          else
            to:drawCards(num, fangzhu.name)
            if not to.dead then
              to:turnOver()
            end
          end
        else
          if room:askToSkillInvoke(to, {
            prompt = "#hs__fangzhu-ask:::"..num,
            skill_name = fangzhu.name,
          }) then
            if not to.dead then
              room:loseHp(to, 1, fangzhu.name)
            end
          else
            if not to.dead then
              to:turnOver()
            end
          end
        end
      end,
})

Fk:loadTranslationTable{
    ["hs__fangzhu"] = "放逐",
    [":hs__fangzhu"] = "当你受到伤害后，你可以令一名其他角色选择一项：1.弃置X张牌并失去1点体力；2.摸X张牌并叠置（X为你已损失的体力值）。",

    ["#hs__fangzhu-choose"] = "放逐：你可令一名其他角色选择摸%arg张牌并叠置，或弃置%arg张牌并失去1点体力",
    ["#hs__fangzhu-ask"] = "放逐：弃置%arg张牌并失去1点体力，或点击“取消”，摸%arg张牌并叠置",

    ["$hs__fangzhu1"] = "死罪可免，活罪难赦！",
    ["$hs__fangzhu2"] = "给我翻过来！",
}

return fangzhu